using MySql.Data.MySqlClient;

namespace Demo
{
    internal static class MySqlCollationHelper
    {
        private const string CollationName = "utf8mb4_general_ci";

        internal static void EnsureGeneralCollation(MySqlConnection connection)
        {
            using var setNames = new MySqlCommand($"SET NAMES utf8mb4 COLLATE {CollationName};", connection);
            setNames.ExecuteNonQuery();

            using var setConnectionCollation = new MySqlCommand($"SET collation_connection = '{CollationName}';", connection);
            setConnectionCollation.ExecuteNonQuery();
        }
    }
}

